#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QTcpSocket>
#include <QString>
#include <QUrl>

class TcpClient : public QObject {
    Q_OBJECT
public:
    explicit TcpClient(QObject* parent, const QString& url);
    ~TcpClient();
    bool setUrl(const QString& url);
    bool initSocket();
    bool postRequest(const QByteArray& postData);
    void freeSocket();
signals:
    void signal_response(const QByteArray& partialResponse);
    void signal_finished(const QByteArray& partialResponse);
private:
    QTcpSocket* socket = nullptr;
    QString host;
    QString path;
    int port;
    
    void slot_readyRead();
    void slot_disconnected();
};

#endif
